package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingLevelServiceImpl implements NursingLevelService {
    @Autowired
    private NursingLevelMapper nursingLevelMapper;

    /**
     * 条件分页查询
     * */

    @Override
    public PageResponse<NursingLevelVo> pageLevel(String name, Integer pageNum, Integer pageSize, Integer status) {
        //设置分页参数
        PageHelper.startPage(pageNum,pageSize);
        //查询
        Page<NursingLevel> pageInfo = nursingLevelMapper.pageLevel(name,status);
        return PageResponse.of(pageInfo, NursingLevelVo.class);
    }

    @Override
    public List<NursingLevel> listAll() {
        return nursingLevelMapper.listAll();
    }

    @Override
    public void insert(NursingLevelDto dto) {
        NursingLevel nursingLevel = BeanUtil.toBean(dto, NursingLevel.class);
        nursingLevelMapper.insert(nursingLevel);
    }

    @Override
    public void update(NursingLevelDto nursingLevelDto) {

        nursingLevelMapper.update(nursingLevelDto);
    }

    @Override
    public void delete(Long id) {
        nursingLevelMapper.delete(id);
    }

    @Override
    public NursingLevelVo getById(Long id) {
        NursingLevelVo nursingLevelVo=new NursingLevelVo();
        NursingLevel nursingLevel = nursingLevelMapper.findById(id);
        BeanUtil.copyProperties(nursingLevel,nursingLevelVo);
        return nursingLevelVo;
    }
}

